package com.wanmait.movies.util;

import java.io.File;
import java.util.UUID;

import com.oreilly.servlet.multipart.FileRenamePolicy;

public class ChangeName implements FileRenamePolicy{
	
	private ChangeName() {};
	private static ChangeName ch = new ChangeName();
	public  static ChangeName getCH() {
		return ch;
	}
	public File rename(File file) {//������ԭ�ļ�
		String filepath = file.getParent();//�õ�ԭ�ļ���·��
		String oldname = file.getName();//�õ�ԭ�ļ�������
		int index = oldname.lastIndexOf(".");//�ҵ���׺���ڵ��±�
		String fileleet = oldname.substring(index+1);//ȡ����׺
		String newname = UUID.randomUUID().toString();//��д������
		File newFile = new File(filepath + "/" + newname + "." + fileleet);//����
		return newFile;
	}
}
